<% layout('/layouts/default.html', {title: '会员管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa icon-user"></i> ${text('会员管理')}
			</div>
			<div class="box-tools pull-right">
				<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
				<% if(hasPermi('shop:memUser:edit')){ %>
					<a href="${ctx}/shop/memUser/form?op=add" class="btn btn-default btnTool" title="${text('新增会员')}"><i class="fa fa-plus"></i> ${text('新增')}</a>
				<% } %>
				<a href="#" class="btn btn-default" id="btnSetting" title="${text('设置')}"><i class="fa fa-navicon"></i></a>
			</div>
		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${memUser}" action="${ctx}/shop/memUser/listData" method="post" class="form-inline "
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
				<#form:hidden name="ctrlPermi" value="${@Global.getConfig('user.adminCtrlPermi', '2')}"/>
				<div class="form-group">
					<label class="control-label">${text('登录账号')}：</label>
					<div class="control-inline">
						<#form:input path="loginCode" maxlength="100" class="form-control width-90"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('用户名称')}：</label>
					<div class="control-inline">
						<#form:input path="userName" maxlength="100" class="form-control width-90"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('手机')}：</label>
					<div class="control-inline">
						<#form:input path="mobile" maxlength="100" class="form-control width-90"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('状态')}：</label>
					<div class="control-inline width-90">
						<#form:select path="status" dictType="sys_user_status" blankOption="true" class="form-control isQuick"/>
					</div>
				</div>
				<!-- <div class="form-row"></div> -->
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</#form:form>
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>
// 初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [
		{header:'${text("登录账号")}', name:'loginCode', index:'a.login_code', width:200, align:"center", frozen:true, formatter: function(val, obj, row, act){
			return '<a href="${ctx}/shop/memUser/form?userCode='+row.userCode+'&op=edit" class="btnList" data-title="${text("编辑会员")}">'+(val||row.id)+'</a>';
		}},
		{header:'${text("用户名称")}', name:'userName', index:'a.user_name', width:200, align:"center"},
		{header:'${text("员工姓名")}', name:'refName', index:'a.ref_name', width:200, align:"center"},
		{header:'${text("电子邮箱")}', name:'email', index:'a.email', width:200, align:"center"},
		{header:'${text("手机号码")}', name:'mobile', index:'a.mobile', width:200, align:"center"},
		{header:'${text("办公电话")}', name:'phone', index:'a.phone', width:200, align:"center"},
		{header:'${text("更新时间")}', name:'updateDate', index:'a.update_date', width:200, align:"center"},
		{header:'${text("状态")}', name:'status', index:'a.status', width:140, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('sys_status')}, val, '未知', true);
		}},
		{header:'${text("操作")}', name:'actions', width:270, sortable:false, title:false, formatter: function(val, obj, row, act){
			var actions = [];
			<% if(hasPermi('shop:memUser:edit')){ %>
				actions.push('<a href="${ctx}/shop/memUser/form?userCode='+row.userCode+'&op=edit" class="btnList" title="${text("编辑会员")}"><i class="fa fa-pencil"></i></a>&nbsp;');
			<% } %>
			<% if(hasPermi('shop:memUser:updateStatus')){ %>
				if (row.status == Global.STATUS_NORMAL){
					actions.push('<a href="${ctx}/shop/memUser/disable?userCode='+row.userCode+'" class="btnList" title="${text("停用会员")}" data-confirm="${text("确认要停用该会员吗？")}"><i class="glyphicon glyphicon-ban-circle"></i></a>&nbsp;');
				}else if (row.status == Global.STATUS_DISABLE || row.status == Global.STATUS_FREEZE || row.status == Global.STATUS_AUDIT){
					actions.push('<a href="${ctx}/shop/memUser/enable?userCode='+row.userCode+'" class="btnList" title="${text("启用会员")}" data-confirm="${text("确认要启用该会员吗？")}"><i class="glyphicon glyphicon-ok-circle"></i></a>&nbsp;');
				}
			<% } %>
			<% if(hasPermi('shop:memUser:edit')){ %>
				actions.push('<a href="${ctx}/shop/memUser/delete?userCode='+row.userCode+'" class="btnList" title="${text("删除会员")}" data-confirm="${text("确认要删除该会员吗？")}"><i class="fa fa-trash-o"></i></a>&nbsp;');
			<% } %>
			<% if(hasPermi('shop:memUser:authRole,shop:memUser:authDataScope,shop:memUser:resetpwd', 'or')){ %>
				actions.push('<a href="javascript:" class="btnMore" title="${text("更多操作")}"><i class="fa fa-chevron-circle-right"></i></a>&nbsp;');
				actions.push('<div class="moreItems">');
				<% if(hasPermi('shop:memUser:authRole')){ %>
					actions.push('<a href="${ctx}/shop/memUser/form?userCode='+row.userCode+'&op=auth" class="btn btn-default btn-xs btnList" title="${text("会员分配角色")}"><i class="fa fa-check-square-o"></i> ${text("分配角色")}</a>&nbsp;');
				<% } %>
				<% if(hasPermi('shop:memUser:resetpwd')){ %>
					actions.push('<a href="${ctx}/shop/memUser/resetpwd?userCode='+row.userCode+'" class="btn btn-default btn-xs btnList" title="${text("会员密码重置")}" data-confirm="${text("确认要将该会员密码重置到初始状态吗？")}"><i class="fa fa-reply-all"></i> ${text("重置密码")}</a>&nbsp;');
				<% } %>
				actions.push('</div>');
			<% } %>
			return actions.join('');
		}}
	],
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
</script>